<!--
	作者：2575202388@qq.com
	时间：2018-10-14
	描述：基础设置顶部
-->

<template>
	<div style="height:800px;">
		<div style="padding-top:10px;width:100%;">
			<Form ref="params" :label-width="300" label-position="right">		
				<div style="width:100%;height: 60px;line-height: 60px;float:left;display:table;">
					<div style="width: 100%;text-align: left;float: left;" align="left">
						<FormItem label="说明:" >如果没有设置儿童入学出生年月起止日期,则默认招收2-3岁的儿童，年龄按照登记截止日期计算
						</FormItem>
					</div>
				</div>
				
				<div style="width:100%;height: 60px;line-height: 60px;float:left;display:table;">
					<div style="width: 50%;text-align: left;float: left;" align="left">
						<FormItem label="是否开启登记" >
							<RadioGroup v-model="params.sfkqbm">
						        <Radio label="开启"></Radio>
						        <Radio label="关闭"></Radio>
						    </RadioGroup>
						</FormItem>
					</div>
				</div>
	
	
				<div style="width:100%;height: 60px;line-height: 60px;float:left;display:table;">
					<div style="width: 50%;text-align: left;float: left;" align="left">
						<FormItem label="登记截止日期" >
							<DatePicker v-model="skTime" @on-change="sjchange" transfer type="datetime" format="yyyy-MM-dd HH:mm" placeholder="请选择登记截止日期" style="width:70%"></DatePicker>
						</FormItem>
					</div>
				</div>
	
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 60%;text-align: left;float: left;" align="left">
						<FormItem label="儿童入学出生年月起止日期" >
							<DatePicker v-model="ruxueks" @on-change="rxstartchange" :options="startTimeOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择入学儿童的出生年月起" 
								style="width:45%;float:left;"></DatePicker>
								<label style="width:5%;text-align: center;float:left;">至</label>
							<DatePicker v-model="ruxuejs" @on-change="rxendchange" :options="endTimeOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择入学儿童的出生年月止" 
								style="width:45%;float:left;"></DatePicker>
						</FormItem>
					</div>
				</div>
				
        
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 60%;text-align: left;float: left;" align="left">
						<FormItem label="亲子班入学儿童出生年月起止" >
							<DatePicker v-model="qzbks" @on-change="qzbstartchange" :options="qzbksOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择亲子班入学儿童出生年月起" 
								style="width:45%;float:left;"></DatePicker>
								<label style="width:5%;text-align: center;float:left;">至</label>
							<DatePicker v-model="qzbjs" @on-change="qzbendchange" :options="qzbjsOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择亲子班入学儿童出生年月止" 
								style="width:45%;float:left;"></DatePicker>
						</FormItem>
					</div>
				</div>
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 60%;text-align: left;float: left;" align="left">
						<FormItem label="小班入学儿童出生年月起止" >
							<DatePicker v-model="xbks" @on-change="xbstartchange" :options="xbksOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择小班入学儿童出生年月起" 
								style="width:45%;float:left;"></DatePicker>
								<label style="width:5%;text-align: center;float:left;">至</label>
							<DatePicker v-model="xbjs" @on-change="xbendchange" :options="xbjsOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择小班入学儿童出生年月止" 
								style="width:45%;float:left;"></DatePicker>
						</FormItem>
					</div>
				</div>
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 60%;text-align: left;float: left;" align="left">
						<FormItem label="中班入学儿童出生年月起止" >
							<DatePicker v-model="zbks" @on-change="zbstartchange" :options="zbksOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择中班入学儿童出生年月起" 
								style="width:45%;float:left;"></DatePicker>
								<label style="width:5%;text-align: center;float:left;">至</label>
							<DatePicker v-model="zbjs" @on-change="zbendchange" :options="zbjsOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择中班入学儿童出生年月至" 
								style="width:45%;float:left;"></DatePicker>
						</FormItem>
					</div>
				</div>
				<div style="width:100%;height: 60px;line-height: 60px;float:left;">
					<div style="width: 60%;text-align: left;float: left;" align="left">
						<FormItem label="大班入学儿童出生年月起止" >
							<DatePicker v-model="dbks" @on-change="dbstartchange" :options="dbksOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择大班入学儿童出生年月起" 
								style="width:45%;float:left;"></DatePicker>
								<label style="width:5%;text-align: center;float:left;">至</label>
							<DatePicker v-model="dbjs" @on-change="dbendchange" :options="dbjsOption" transfer type="datetime" format="yyyy-MM-dd" placeholder="请选择大班入学儿童出生年月至" 
								style="width:45%;float:left;"></DatePicker>
						</FormItem>
					</div>
				</div>
				
				
				<div style="width:100%;float:left;">
					<div style="width: 60%;float: left;height:200px;" align="left">
						<FormItem label="首页温馨提示" >
						  <quill-editor v-model="params.wxts" ref="myQuillEditor" :options="editorOption">
				          </quill-editor>
						</FormItem>
					</div>
				</div>
				
			</Form>	
		</div>
		<div style="width:100%;height: 60px;line-height: 60px;float:left;margin-bottom: 20px;">
			<Button type="info" style="float:left;margin-left:10%;" v-on:click="save()">保存</Button>
		</div>	
	</div>
</template>
<script>
	
	export default {
		name:"home",
		
		data() {

			const toolbarOptions = [
		      ['bold', 'italic', 'underline'],
		      [{'size': ['small', false, 'large', 'huge']}],
		      [{'color': []}, {'background': []}],          // dropdown with defaults from theme
		      [{'font': []}],
		      [{'align': []}]           
		    ];
		 
			return {
				skTime:null,
				ruxueks:null,
				ruxuejs:null,
				qzbks:null, //亲子班儿童入学年龄起
				qzbjs:null, //亲子班儿童入学年龄至
				xbks:null, //小班儿童入学年龄起
				xbjs:null,  //小班儿童入学年龄至
				zbks:null, //中班儿童入学年龄起
				zbjs:null,  //中班儿童入学年龄至
				dbks:null, //大班儿童入学年龄起
				dbjs:null,//大班儿童入学年龄至
				
				startTimeOption: {},
                endTimeOption: {},
                
                qzbksOption: {},//亲子班儿童入学年龄起
                qzbjsOption: {},//亲子班儿童入学年龄至
                xbksOption: {},//小班儿童入学年龄起
                xbjsOption: {},//小班儿童入学年龄至
                zbksOption: {},//中班儿童入学年龄起
                zbjsOption: {}, //中班儿童入学年龄至
                dbksOption: {},//大班儿童入学年龄起
                dbjsOption: {},//大班儿童入学年龄至
                
				params:{
					sfkqbm:'开启',
					bmjzrq:'',//登记截止日期
					rxstart:'',//儿童入学开始日期
					rxend:'',//儿童入学结束日期
					wxts:'',//首页温馨提示

					qzbstart:'', //亲子班儿童入学年龄起
					qzbend:'', //亲子班儿童入学年龄至
					xbstart:'', //小班儿童入学年龄起
					xbend:'',  //小班儿童入学年龄至
					zbstart:'', //中班儿童入学年龄起
					zbend:'',  //中班儿童入学年龄至
					dbstart:'', //大班儿童入学年龄起
					dbend:''//大班儿童入学年龄至
				},
				
				
                
				editorOption: {//富文本编辑器的工具栏
				  modules: {
				    toolbar:{
				      container: toolbarOptions,  // 工具栏
				    },
				  },
				  imageResize: {}, //自定义拉伸
				  placeholder: '请输入文章内容',
				},

			}
		},
		components: {
			
		},
		computed: {
			
		},
		methods: {
			getSystemInfo(){
				this.$http.get("/host/bmxt/home/getSystemInfo.html")
				.then(result => {
					if(result.BMJZRQ){
						this.params.bmjzrq=result.BMJZRQ;
						this.skTime=new Date(this.params.bmjzrq);
					}
					
					//儿童入学出生年月起止日期
					if(result.RXSTART){
						this.params.rxstart=result.RXSTART;
						this.ruxueks=new Date(this.params.rxstart);
					}
					if(result.RXEND){
						this.params.rxend=result.RXEND;
						this.ruxuejs=new Date(this.params.rxend);
					}


					//亲子班儿童入学年龄起至
					if(result.QZBSTART){
						this.params.qzbstart=result.QZBSTART;
						this.qzbks=new Date(this.params.qzbstart);
					}
					if(result.QZBEND){
						this.params.qzbend=result.QZBEND;
						this.qzbjs=new Date(this.params.qzbend);
					}
					
					
					//小班儿童入学年龄起至
					if(result.XBSTART){
						this.params.xbstart=result.XBSTART;
						this.xbks=new Date(this.params.xbstart);
					}
					if(result.XBEND){
						this.params.xbend=result.XBEND;
						this.xbjs=new Date(this.params.xbend);
					}

					//中班儿童入学年龄起至
					if(result.ZBSTART){
						this.params.zbstart=result.ZBSTART;
						this.zbks=new Date(this.params.zbstart);
					}
					if(result.ZBEND){
						this.params.zbend=result.ZBEND;
						this.zbjs=new Date(this.params.zbend);
					}
					
					//大班儿童入学年龄起至
					if(result.DBSTART){
						this.params.dbstart=result.DBSTART;
						this.dbks=new Date(this.params.dbstart);
					}
					if(result.DBEND){
						this.params.dbend=result.DBEND;
						this.dbjs=new Date(this.params.dbend);
					}
					
					
					if(result.WXTS){
						this.params.wxts=result.WXTS;
					}
					
					if(result.SFKQBM){
						if(result.SFKQBM=="1"){
							this.params.sfkqbm="关闭";
						}else{
							this.params.sfkqbm="开启";
						}
					}
					
				});
			},
			
			
			save(){
				var sfkqbm="0";
				if(this.params.sfkqbm=="关闭"){
					sfkqbm="1";
				}
				
				var bmjzrq=this.params.bmjzrq;
				var rxstart=this.params.rxstart;
				var rxend=this.params.rxend;
				if(bmjzrq=="" && rxstart=="" && rxend==""){
					this.$Modal.error({
                        title: "提示",
                        content:"登记截止日期与儿童入学出生年月起止日期,请至少填写一项!"
                    });	
                    return;
				}else{
					if((rxstart!="" && rxend=="") || (rxstart=="" && rxend!="")){
						this.$Modal.error({
	                        title: "提示",
	                        content:"儿童入学出生年月起止日期不能只选择一项填写!"
	                    });	
	                    return;
					}
				}
				
				//亲子班儿童入学年龄起至
				var qzbstart=this.params.qzbstart; //亲子班儿童入学年龄起
				var qzbend=this.params.qzbend;//亲子班儿童入学年龄至
				if(qzbstart==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写亲子班儿童入学出生年月起!"
	                });	
	                return;
				}
				if(qzbend==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写亲子班儿童入学出生年月至!"
	                });	
	                return;
				}
				
				
				//小班儿童入学年龄起至
				var xbstart=this.params.xbstart; //小班儿童入学年龄起
				var xbend=this.params.xbend;//小班儿童入学年龄至
				if(xbstart==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写小班儿童入学出生年月起!"
	                });	
	                return;
				}
				if(xbend==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写小班儿童入学出生年月至!"
	                });	
	                return;
				}
				
				//中班儿童入学年龄起至
				var zbstart=this.params.zbstart; //小班儿童入学年龄起
				var zbend=this.params.zbend;//小班儿童入学年龄至
				if(zbstart==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写中班儿童入学出生年月起!"
	                });	
	                return;
				}
				if(zbend==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写中班儿童入学出生年月至!"
	                });	
	                return;
				}
				
				//大班儿童入学年龄起至
				var dbstart=this.params.dbstart; //大班儿童入学年龄起
				var dbend=this.params.dbend;//大班儿童入学年龄至
				if(dbstart==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写大班儿童入学出生年月起!"
	                });	
	                return;
				}
				if(dbend==""){
					this.$Modal.error({
	                    title: "提示",
	                    content:"请填写大班儿童入学出生年月至!"
	                });	
	                return;
				}
					
				
				var wxts=this.params.wxts;
				const params={
					sfkqbm:sfkqbm,
					bmjzrq:bmjzrq,
					rxstart:rxstart,
					rxend:rxend,
					qzbstart:qzbstart, //亲子班儿童入学年龄起
					qzbend:qzbend, //亲子班儿童入学年龄至
					xbstart:xbstart, //小班儿童入学年龄起
					xbend:xbend,  //小班儿童入学年龄至
					zbstart:zbstart, //中班儿童入学年龄起
					zbend:zbend,  //中班儿童入学年龄至
					dbstart:dbstart, //大班儿童入学年龄起
					dbend:dbend,//大班儿童入学年龄至
					wxts:wxts
				}
				this.$http.post("/host/bmxt/home/updateSystemInfo.html",params)
				.then(datas => {
					if(datas){
						this.$Modal.success({
                            title: "提示",
                            content: "保存成功"
                        });	
					}else{
						this.$Modal.error({
                            title: "提示",
                            content:"保存失败"
                        });	
					}
				});	
			},
			
			
			sjchange(e){
				this.params.bmjzrq=e;
			},
			rxstartchange(e){
				this.params.rxstart=e;
				this.endTimeOption = {
                 	disabledDate(ruxuejs) {
                    	return ruxuejs < new Date(e) 
                    }
             	}
				
			},
			rxendchange(e){
				this.params.rxend=e;
				this.startTimeOption = {
                    disabledDate(ruxueks) {
                        return ruxueks > new Date(e) || ruxueks > Date.now()
                    }
                }
			},
			
			//亲子班儿童入学年龄起至
			qzbstartchange(e){
				this.params.qzbstart=e;
				this.qzbjsOption = {
                 	disabledDate(qzbend) {
                    	return qzbend < new Date(e) 
                    }
             	}
			},
			qzbendchange(e){
				this.params.qzbend=e;
				this.qzbksOption = {
                    disabledDate(qzbstart) {
                        return qzbstart > new Date(e) || qzbstart > Date.now()
                    }
                }
			},
                
			//小班儿童入学年龄起至
			xbstartchange(e){
				this.params.xbstart=e;
				this.xbjsOption = {
                 	disabledDate(xbend) {
                    	return xbend < new Date(e) 
                    }
             	}
			},
			xbendchange(e){
				this.params.xbend=e;
				this.xbksOption = {
                    disabledDate(xbstart) {
                        return xbstart > new Date(e) || xbstart > Date.now()
                    }
                }
			},
          
			//中班儿童入学年龄起至
			zbstartchange(e){
				this.params.zbstart=e;
				this.zbjsOption = {
                 	disabledDate(zbend) {
                    	return zbend < new Date(e) 
                    }
             	}
			},
			zbendchange(e){
				this.params.zbend=e;
				this.zbksOption = {
                    disabledDate(zbstart) {
                        return zbstart > new Date(e) || zbstart > Date.now()
                    }
                }
			},
			

			//大班儿童入学年龄起至
			dbstartchange(e){
				this.params.dbstart=e;
				this.dbjsOption = {
                 	disabledDate(dbend) {
                    	return dbend < new Date(e) 
                    }
             	}
			},
			dbendchange(e){
				this.params.dbend=e;
				this.dbksOption = {
                    disabledDate(dbstart) {
                        return dbstart > new Date(e) || dbstart > Date.now()
                    }
                }
			},	
				      
			
		}, 
		mounted(){	
			//获取系统基本信息
			this.getSystemInfo();
		},
		watch:{
			
		},
	}
</script>

<style>
</style>



